﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace Test
{
    public enum AreaType
    {
        Start,
        PreTown,
        Town,
        PostTown,
        End
    }

    class Area
    {
        private Point position;
        private AreaType type;
        private int level;
        private HashSet<Area> next;
        private HashSet<Area> previous;

        public Area()
        {
            this.level = 0;
            this.position = new Point();
            this.next = new HashSet<Area>();
            this.previous = new HashSet<Area>();
        }

        public Point Position 
        {
            get { return position; }
            set { position = value; }
        }

        public int Level
        {
            get { return level; }
            set { level = value; }
        }


        public HashSet<Area> Next
        {
            get { return next; }
        }

        public HashSet<Area> Previous
        {
            get { return Previous; }
        }

        public AreaType Type
        {
            get { return type; }
            set { type = value; }
        }


        public void setNext(Area area, Boolean reciprocal)
        {
            this.next.Add(area);
            if (reciprocal) area.setPrevious(this, false);
        }

        public void setPrevious(Area area, Boolean reciprocal)
        {
            this.previous.Add(area);
            if (reciprocal) area.setNext(this, false);
        }

        public double distance(Point p)
        {
            return Math.Sqrt(Math.Pow(this.position.X - p.X, 2) + Math.Pow(this.position.Y - p.Y, 2));
        }
    }
}
